﻿@using Bonobo.Git.Server.Extensions;
@model TeamDetailModelList
@{
    ViewBag.Title = Resources.Team_Index_Title;
}

<div class="pure-g">
    <div class="pure-u-3-5">
        <h1>@Resources.Team_Index_Title</h1>
    </div>
    @if (!Model.IsReadOnly)
    {
        <div class="pure-u-2-5 add">
        <a class="pure-button pure-button-primary" href="@Url.Action("Create")"><i class="fa fa-plus-circle"></i> @Resources.Team_Index_CreateNew</a>
        </div>
    }
</div>

@if (TempData["CreateSuccess"] != null && (bool)TempData["CreateSuccess"])
{
    <div class="summary-success">
        <p id="@TempData["NewTeamId"]">@Resources.Team_Create_Success</p>
    </div>
}
@if (TempData["DeleteSuccess"] != null && (bool)TempData["DeleteSuccess"])
{
    <div class="summary-success">
        <p>@Resources.Team_Delete_Success</p>
    </div>
}

@{
    var grid = new WebGrid(source: Model, defaultSort: "Name", rowsPerPage: 15);
}

<div class="w-grid">
    @grid.GetHtml(
        tableStyle: "pure-table teams",
        columns: grid.Columns(
            grid.Column(header: typeof(TeamDetailModel).GetDisplayValue("Name"), format: (item) => Html.ActionLink((string)item.Name, "Detail", new { id = item.Id }, new { @class = "detail" })),
            grid.Column("Description", typeof(TeamDetailModel).GetDisplayValue("Description"), format: (item) => item.Description != null && ((string)item.Description).Length > 100 ? ((string)item.Description).Substring(0, 100) + " (...) " : item.Description),
            grid.Column(format: (item) => item.IsReadOnly ? Html.Raw(String.Empty) : Html.ActionLink(" ", "Edit", new { id = item.Id }, new { @class = "edit", title = Resources.Grid_Edit }), style: "action"),
            grid.Column(format: (item) => item.IsReadOnly ? Html.Raw(String.Empty) : Html.ActionLink(" ", "Delete", new { id = item.Id }, new { @class = "delete", title = Resources.Grid_Delete }), style: "action")
        )
    )
</div>
